import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Dashboard', icon: 'dashboard' }
    }]
  },

  {
    path: '/hotel',
    component: Layout,
    redirect: '/hotel/table',
    name: 'Hotel',
    meta: { title: '酒店信息1', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'table',
        name: 'Table',
        component: () => import('@/views/table/HotelList'),
        meta: { title: '酒店列表', icon: 'table' }
      },
      {
        path: 'table/order',
        name: 'order',
        component: () => import('@/views/table/order/order'),
        meta: { title: '订单列表', icon: 'table' }
      },
      {
        path: 'tree',
        name: 'Tree',
        component: () => import('@/views/tree/index'),
        meta: { title: 'Tree', icon: 'tree' }
      },
      {
        path: 'updateHotel/:id',
        name: 'UpdateHotel',
        component: () => import('@/views/table/updateHotel'),
        meta: { title: '修改酒店信息', icon: 'tree' },
        hidden: true
      },
      {
        path: 'addHotel',
        name: 'addHotel',
        component: () => import('@/views/table/addHotel'),
        meta: { title: '新增酒店信息', icon: 'tree' },
        hidden: true
      },
      {
        path: 'hotelPicture/:id',
        name: 'HotelPicture',
        component: () => import('@/views/table/hotelPicture'),
        meta: { title: '酒店图片', icon: 'tree' },
        hidden: true
      }
    ]
  },

  {
    path: '/report',
    component: Layout,
    redirect: '/report/table',
    name: 'Report',
    meta: { title: '报表管理', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'reportform',
        name: 'reportform',
        component: () => import('@/views/reportmodel/report'),
        meta: { title: '报表概况', icon: 'table' }
      }, {
        path: 'reportform',
        name: 'reportform',
        component: () => import('@/views/reportmodel/report'),
        meta: { title: '报表概况', icon: 'table' }
      },
    ]
  },{
    path: '/bed',
    component: Layout,
    redirect: '/bed/table',
    name: 'Bed',
    meta: { title: '床位管理', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'bedlist',
        name: 'bedlist',
        component: () => import('@/views/bedmodel/bedlist'),
        meta: { title: '床位管理', icon: 'table' }
      },
      {
        path: 'bedmessage/:id',
        name: 'bedmessage',
        component: () => import('@/views/bedmodel/bedmessage'),
        meta: { title: 'bedmessage', icon: 'table' },
        hidden:true
      },
      {
        path: 'bedadd',
        name: 'bedadd',
        component: () => import('@/views/bedmodel/bedadd'),
        meta: { title: 'bedadd', icon: 'table' },
        hidden:true
      }
    ]
  },
  {
    path: '/cus',
    component: Layout,
    redirect: '/cus/customer',
    name: 'cus',
    meta: { title: '用户管理', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'customer',
        name: 'Table',
        component: () => import('@/views/customer/HotelList'),
        meta: { title: '用户管理', icon: 'table' }
      },
      {
        path: 'updateHotel/:id',
        name: 'UpdateHotel',
        component: () => import('@/views/customer/updateHotel'),
        meta: { title: '修改酒店信息', icon: 'tree' },
        hidden: true
      },
      {
        path: 'addHotel',
        name: 'addHotel',
        component: () => import('@/views/customer/addHotel'),
        meta: { title: '新增酒店信息', icon: 'tree' },
        hidden: true
      },
      {
        path: 'hotelPicture/:id',
        name: 'HotelPicture',
        component: () => import('@/views/customer/hotelPicture'),
        meta: { title: '酒店图片111', icon: 'tree' },
        hidden: true
      },
      {
 
        path: 'order',
        name: 'order',
        component: () => import('@/views/order/order'),
        meta: { title: '订单详情1', icon: 'table' }
      },
      
      

    ]
  },

  {
    path: '/hospital',
    component: Layout,
    redirect: '/hospital/hospitalList',
    name: 'Hospital',
    meta: {
      title: '医院管理',
      icon: 'nested'
    },
    children: [
      {
        path: 'hospitalList',
        component: () => import('@/views/hospital/hospitalList'), // Parent router-view
        name: 'HospitalList',
        meta: { title: '医院' },
      },
      {
        path: 'hospitalDeptList',
        component: () => import('@/views/hospital/hospitalDeptList'),
        name: 'HospitalDeptList',
        meta: { title: '科室' }
      },
      {
        path: 'addHospital',
        component: () => import('@/views/hospital/addHospital'),
        name: 'AddHospital',
        meta: { title: '新增医院' },
        hidden:true
      },
      {
        path: 'hospitalDetail/:id',
        component: () => import('@/views/hospital/hospitalDetail'),
        name: 'HospitalDetail',
        meta: { title: '医院详情' },
        hidden:true
      },
      {
        path: 'updateHospital/:id',
        component: () => import('@/views/hospital/updateHospital'),
        name: 'UpdateHospital',
        meta: { title: '编辑医院' },
        hidden:true
      },
      {
        path: 'addHospitalDept',
        component: () => import('@/views/hospital/addHospitalDept'),
        name: 'AddHospitalDept',
        meta: { title: '新增科室' },
        hidden:true
      },
      {
        path: 'hospitalDeptDetail/:id',
        component: () => import('@/views/hospital/hospitalDeptDetail'),
        name: 'HospitalDeptDetail',
        meta: { title: '科室详情' },
        hidden:true
      },
      {
        path: 'updateHospitalDept/:id',
        component: () => import('@/views/hospital/updateHospitalDept'),
        name: 'UpdateHospitalDept',
        meta: { title: '编辑科室' },
        hidden:true
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    redirect: '/user/shareholder',
    name: 'User',
    meta: { title: '人员管理', icon: 'user' },
    children: [
      {
        path: 'shareholder',
        name: 'Shareholder',
        component: () => import('@/views/user/shareholder/shareholderList'),
        meta: { title: '股东', icon: 'table' }
      },
      {
        path: 'updateshareholder/:id',
        name: 'Updateshareholder',
        component: () => import('@/views/table/updateHotel'),
        meta: { title: '修改酒店信息', icon: 'tree' },
        hidden:true
      },
      {
        path: 'shareholderInfo/:id',
        name: 'ShareholderInfo',
        component: () => import('@/views/user/shareholder/shareholderInfo'),
        meta: { title: '股东详情', icon: 'tree' },
        hidden:true
      },
      {
        path: 'hotelPicture/:id',
        name: 'HotelPicture',
        component: () => import('@/views/table/hotelPicture'),
        meta: { title: '酒店图片', icon: 'tree' },
        hidden:true
      },
      {
        path: 'areamanager',
        name: 'Areamanager',
        component: () => import('@/views/user/areamanager/areamanagerList.vue'),
        meta: { title: '区域管理员', icon: 'table' }
      },
    ]
  },

  {
    path: '/order',
    component: Layout,
    redirect: '/order/order',
    name: 'order',
    meta: {
      title: '订单管理',
      icon: 'nested'
    },
    children: [
      {
        path: 'order',
        component: () => import('@/views/order/order'),
        name: 'order',
        meta: { title: '订单', icon: 'table' },
      },
      {
        path: 'orderdetails/:id',
        component: () => import('@/views/order/orderdetails'),
        name: 'orderDetails',
        meta: { title: '订单详情', icon: 'tree' },
        hidden: true
      }
    ]
  },
  {
    path: 'external-link',
    component: Layout,
    children: [
      {
        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
        meta: { title: 'External Link', icon: 'link' }
      }
    ]
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
